package self.hoy.demo.cloud;

import org.springframework.cloud.context.named.NamedContextFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import self.hoy.demo.cloud.conf.TestContextAutoConfiguration;

/**
 * @author 三共小不
 * @date 2021/7/5
 */
public class MyTestContextFactory extends NamedContextFactory<TestSpecification> {
    public MyTestContextFactory() {
        // 指定子context需要加载自动化配置类
        super(TestContextAutoConfiguration.class, "testcontext", "testcontext.name");
    }

    public MyContextBean getMyContextBean(String name) {
        // 自定义接口类型
        return getInstance(name, MyContextBean.class);
    }

    public MyShowContextBean getMyShowContextBean(String name) {
        // 自定义接口类型
        return getInstance(name, MyShowContextBean.class);
    }

    @Override
    protected AnnotationConfigApplicationContext getContext(String name) {
        return super.getContext(name);
    }

    public void setProperties() {}
}
